package com.mxf.code.sentinel;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author : [mxf]
 * @version : [v1.0]
 * @className : HanderOriginParser
 * @description : [描述说明该类的功能]
 * @createTime : [2022/9/24 21:08]
 * @updateUser : [mxf]
 * @updateTime : [2022/9/24 21:08]
 * @updateRemark : [描述说明本次修改内容]
 */
@Component
@Order(0)
public class HanderOriginParser implements RequestOriginParser {

    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        String origin = httpServletRequest.getHeader("origin");
        if (StringUtils.isEmpty(origin)){
            origin = "blank";
        }
        return origin;
    }
}
